
var app=new Vue({
  el:"#register",
  data: {
    user:{},
    result:{},
    message:"",
    password:"",
    code:""
  },
  methods: {/*注册*/
      register: function () {
          if (this.user.password != this.password) {
              alert("两次密码输入不一致");
          } else {
              axios.post("/user/register.do?code=" + this.code, this.user).then(function (response) {
                  if (response.data.success) {
                      alert(response.data.message);
                      this.result = response.data;
                      console.log(this.result);
                      window.location.href = '/login.html';
                  } else {
                      alert(response.data.message);
                  }

              }).catch(function (error) {
                  console.log(error);
              });
          }
      },
      /*发送邮箱验证码*/
      checkCode: function () {
          axios.post("/user/code.do", this.user).then(function (response) {
              if (response.data.message) {
                  this.message = response.data.message;
                  alert(this.message);
              } else {
                  alert("发送失败");
              }
          }).catch(function (error) {
              console.log(error);
          })
      }
  }
})
/*通过邮箱找回密码*/
var app2=new Vue({
  el:"#emailLogin",
  data: {
    user:{}
  },
  methods: {
    findPassword:function (){
      axios.post("/user/selectPassword.do",this.user).then(function (response){
        if(response.data.success){
          alert(response.data.message);
          window.location.href='/login.html';
        }else{
          alert(response.data.message);
          location.reload();
        }
      }).catch(function (error) {
        console.log(error);
      });
    }
  }
})
